<?php
declare(strict_types=1);

namespace app\admin\validate;

use think\Validate;

class MenuValidate extends Validate
{
    protected $rule = [
        'menu_id' => 'require|number',
        'parent_id' => 'number',
        'name' => 'max:32',
        'path' => 'max:255',
        'component' => 'max:255',
        'redirect' => 'max:255',
        'title' => 'require|max:32',
        'icon' => 'max:32',
        'is_custom_svg' => 'in:0,1',
        'type' => 'require|in:1,2',
        'perms' => 'max:100',
        'sort' => 'number',
        'status' => 'in:0,1',
        'no_keep_alive' => 'in:0,1',
        'hidden' => 'in:0,1'
    ];

    protected $message = [
        'menu_id.require' => '菜单ID不能为空',
        'menu_id.number' => '菜单ID必须为数字',
        'parent_id.number' => '父级ID必须为数字',
        'name.max' => '路由名称最多32个字符',
        'path.max' => '路由路径最多255个字符',
        'component.max' => '组件路径最多255个字符',
        'redirect.max' => '重定向地址最多255个字符',
        'title.require' => '菜单标题不能为空',
        'title.max' => '菜单标题最多32个字符',
        'icon.max' => '图标最多32个字符',
        'is_custom_svg.in' => '自定义图标值只能是0或1',
        'type.require' => '菜单类型不能为空',
        'type.in' => '菜单类型值只能是1或2',
        'perms.max' => '权限标识最多100个字符',
        'sort.number' => '排序必须为数字',
        'status.in' => '状态值只能是0或1',
        'no_keep_alive.in' => '是否缓存值只能是0或1',
        'hidden.in' => '是否隐藏值只能是0或1'
    ];

    protected $scene = [
        'add' => ['parent_id', 'name', 'path', 'component', 'redirect', 'title', 'icon', 'is_custom_svg', 'type', 'perms', 'sort', 'status', 'no_keep_alive', 'hidden'],
        'edit' => ['menu_id', 'parent_id', 'name', 'path', 'component', 'redirect', 'title', 'icon', 'is_custom_svg', 'type', 'perms', 'sort', 'status', 'no_keep_alive', 'hidden']
    ];
} 